[DX-285] React Native push notifications guide#3228
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
473e3a0 to
31c16f7
Compare
55ea18f to
5b431eb
Compare
09bc9fb to
f86cf42
Compare
7db79f5 to
4de286b
Compare
789d8eb to
02ac81e
Compare
4de286b to
60d24d8
Compare
02ac81e to
9942418
Compare
60d24d8 to
061e171
Compare
splindsay-92
left a comment
There was a problem hiding this comment.
Just an initial comment again on if we should be using ably-js react hooks here. Also, would it make this whole guide a bit simpler/shorted if we made use of the dashboards ability to send notifications to device/clientId/Channel? We could still have basic code segments to show how its done, but there'd be no need for the additional UI/handling (also this page is due for a refurb).
I won't block the guide based on the current design though, but just a thought that might make things cleaner :)
That's a fair point. But I think there is a real trade-off between completeness and brevity here — having the send functionality in the app gives readers something tangible to run themselves rather than deferring to an external interface for the most satisfying part of the exercise. Also, in general we tend to use Ably CLI for interacting with the service anyway. I would prefer to hear from other team members before cutting this. If the consensus is to go leaner, I am happy to make the change. wdyt @sacOO7 @m-hulbert @AndyTWF |
Kotlin, XML, Ruby, and Swift blocks were inside <Code> components, pulling them into the language switcher and causing mismatched tabs for users with a different language selected. These are platform config files that all readers need to see, so they are now plain fenced code blocks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The page is a React Native-only guide with no language switching. Having react blocks inside <Code> caused the global language selector to show Swift and other pubsub languages as options, resulting in empty states for non-react selections. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7bf600f to
97012f7
Compare
- Wrap app in AblyProvider + ChannelProvider - Split App into App (providers) and PushScreen (hooks) - Replace manual useEffect channel subscription with useChannel - Replace module-scope realtime client with useAbly() in PushScreen - Update ably channels publish CLI to ably push publish --channel - Remove scrollViewRef auto-scroll for brevity - Rename appendLog to log Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
97012f7 to
966396e
Compare
m-hulbert
left a comment
There was a problem hiding this comment.
This is getting there Marat. I've just put a few comments in, but I'd say in general we need to be opinionated on a method rather than consistently offer multiple options. Also agree with @splindsay-92 about keeping this simpler where it makes sense / reflects real-world usage.
|
|
||
| Add `use_modular_headers!` to `ios/Podfile` after `prepare_react_native_project!`: | ||
|
|
||
| ```ruby |
There was a problem hiding this comment.
I don't think this should be ruby?
There was a problem hiding this comment.
Podfile is a Ruby file.
| ``` | ||
|
|
||
| <Aside data-type='note'> | ||
| At the time of writing React Native Gradle plugin is not compatible with Gradle 9. If you see a `JvmVendorSpec.IBM_SEMERU` error during the Android build, update `android/gradle/wrapper/gradle-wrapper.properties` to use Gradle 8.13: `distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip`. |
There was a problem hiding this comment.
We should avoid things like 'at time of writing' etc. Can we just state we should use 8.13 instead if it's still not supported in 9?
There was a problem hiding this comment.
I'm now thinking that it's an insignificant implementation detail which can be easily fixed by android developer familiar with android studio enough to dare implement pushes. I'm removing this.
|
|
||
| After successful activation, `deviceId` contains the unique device ID assigned to this installation. | ||
|
|
||
| <Aside data-type='note'> |
There was a problem hiding this comment.
Do we need all this exposition? Three notes in a row suggests this is way too complex. Do we need to explain which methods are used and why?
There was a problem hiding this comment.
Moved two of them in a short code comment.
|
|
||
| ## Step 1: Set up Ably <a id="step-1"/> | ||
|
|
||
| Replace the contents of `App.tsx` with the following to initialize the Ably Realtime client, wrap the app in `AblyProvider` and `ChannelProvider`, and subscribe to a channel for incoming messages using the `useChannel` hook: |
There was a problem hiding this comment.
Should we keep this to the Pub/Sub rather than a 'realtime client' so people know what it is?
| ``` | ||
| </Code> | ||
|
|
||
| The `transportType` is set to `fcm` on both platforms because `messaging().getToken()` always returns an FCM registration token, even on iOS. Firebase exchanges the APNs device token for an FCM token internally, so Ably communicates with Firebase rather than APNs directly (instead Firebase sends push notifications to iOS devices via APNs). |
There was a problem hiding this comment.
Do we need to explain this? Would someone know this if they're React Native devs or familiar with Push? Maybe even a short code comment for iOS would be sufficient?
There was a problem hiding this comment.
Moved to code comment (I'm not sure what you've meant by "for iOS" tho, it's cross-platform js code snippets).
|
|
||
| ## Step 3: Subscribe and test push notifications <a id="step-3"/> | ||
|
|
||
| The FCM SDK handles background push notifications automatically and displays them as system notifications. For foreground handling, use `@notifee/react-native` to display notifications while the app is open. |
There was a problem hiding this comment.
Should we choose one approach or the other? Or explain how to use both.
There was a problem hiding this comment.
I've meant that if a reader wants to display pushes inside their app (foreground), they should use notifee (code example already shows how). If app in the background though, it will be handled by Android itself and displayed in the Notification Center.
| </Code> | ||
|
|
||
| <Aside data-type='note'> | ||
| Sending push notifications using `deviceId` or `clientId` requires the `push-admin` capability for your API key. Use this method for testing purposes. In production, send push notifications from your backend server by publishing messages with a `push` `extras` field to a channel. |
There was a problem hiding this comment.
Could the capabilities be covered in the pre-reqs rather than mid-guide? Which method are we then referring to here?
There was a problem hiding this comment.
Moved to Prerequisites.
|
|
||
| ### Send push via channel <a id="step-4-send-channel"/> | ||
|
|
||
| To test push notifications via channel, tap **Subscribe to Channel** in the app and then send a push notification to the channel using the Ably CLI: |
There was a problem hiding this comment.
There's a lot of 'testing' here and do we need both options? I think I agree with Steven that we should either use the dashboard (or more likely the CLI) for pushing the notifications as you wouldn't tend to be sending via the app in reality.
There was a problem hiding this comment.
Not sure I follow, do you mean to remove code snippet for js and only leave CLI? (js one was Steven suggestion.)
…ge flag and new screenshot Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove 'at time of writing' Gradle note (insignificant impl detail) - Replace 'realtime client' with 'Pub/Sub' - Remove transportType prose; add inline code comment - Move deviceId and requestPermission notes to code comments - Move push-admin capability note to Prerequisites #3 - Split Step 3 into 'Test admin push notifications' and 'Subscribe to channel push notifications' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description
React Native push notifications tutorial.
https://ably.atlassian.net/browse/DX-285
Checklist